<template>
    <div class="app-container">
        <el-card shadow="never">
            <!-- 条件查询 -->
            <el-form v-show="showSearch" ref="queryForm" :model="queryParams" label-width="120px" @keyup.enter.native="submitSearch" @submit.native.prevent>
                <el-row>
                    <el-col :md="6" :sm="12">
                        <el-form-item label="租户:" prop="tenant.name.value">
                            <el-select v-model="queryParams.tenant.name.value" placeholder="请选择租户" clearable>
                                <el-option v-for="(item, index) in tenant.name" :key="index" :label="item.label" :value="item.value" />
                            </el-select>
                        </el-form-item>
                    </el-col>

                    <el-col :md="6" :sm="12">
                        <el-form-item class="ele-text-right" label-width="50px">
                            <el-button type="primary" size="mini" @click="submitSearch" icon="el-icon-search" class="ele-btn-icon">搜索 </el-button>
                            <el-button @click="resetQuery" size="mini" icon="el-icon-refresh">重置</el-button>

                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>


            <!-- 列表 -->
            <qa-table
                :source="tableData"
                :columns="columns"
                :selection="true"
                :loading="loading"
                @sortChange="sortChange"
                @statusChange="statusChange"
                @selectionChange="selectionChange"
                id="quickadmin"
            >
                <template v-slot:action>
                    <el-table-column label="操作" width="180">
                        <template slot-scope="scope">
                            <el-button size="mini" type="text" icon="el-icon-edit" @click="handleEdit(scope.row)" v-hasPermi="api.edit">编辑</el-button>
                            <el-button size="mini" type="text" icon="el-icon-tickets" @click="handleDetail(scope.row)" v-hasPermi="api.find">详情</el-button>
                        </template>
                    </el-table-column>
                </template>
            </qa-table>

            <!-- 分页 -->
            <pagination :total="total" :page.sync="pageInfo.page" :limit.sync="pageInfo.limit" @pagination="initIndex" />
        </el-card>

        <!-- 编辑弹窗 -->
       <el-dialog :title="!disabled ? '编辑' : '详情'" :visible="editOpen" :before-close="beforeClose" destroy-on-close>
            <EditForm ref="editForm" :findFormData="findFormData" :disabled="disabled" @submitForm="submitForm" :editFormParams="editFormParams" @editFormCancel="beforeClose" />
        </el-dialog>
    </div>
</template>

<script>
import { curdMixin } from '@/mixins/curdMixin'
import EditForm from './EditFormCom'
export default {
    name: 'Curd',
    mixins: [curdMixin],
    components: { EditForm },
    data() {
        return {
            // table结构
            columns: [
                {
                    visible: true,
                    label: '编号',
                    prop: 'id',
                },
                {
                    visible: true,
                    label: '账户名称',
                    prop: 'name',
                },
                {
                    visible: true,
                    label: '银行账号',
                    prop: 'bank_account',
                },
                {
                    visible: true,
                    label: '开户行',
                    prop: 'bank',
                },
                {
                    visible: true,
                    label: '状态',
                    prop: 'status_text',
                },
                {
                    visible: true,
                    label: '创建时间',
                    prop: 'create_time',
                    width:'180px'
                },
                {
                    visible: true,
                    label: '更新时间',
                    prop: 'update_time',
                    width:'180px'
                },

                {
                    visible: true,
                    label: '租户',
                    prop: 'tenant.name',
                    formatter: (prop, row) => {
                        return  row.tenant.name
                    },
                },

            ],
            // 接口地址
            api: {
                index: `/admin/ch.bankinfo/index`,
                find: `/admin/ch.bankinfo/find`,
                add: `/admin/ch.bankinfo/add`,
                edit: `/admin/ch.bankinfo/edit`,
                delete: `/admin/ch.bankinfo/delete`,
                export: `/admin/ch.bankinfo/export`,
                status: `/admin/ch.bankinfo/status`
            },
            editFormParams: {
            },
            // 搜索表单是否展开
            searchExpand: false,
            // 查询参数
            queryParams: {
                tenant:{                 name: { value:undefined, op: '='},

                },
            },
                tenant:{             name:[
            ],

                },
        }
    },

    methods: {
        // 案列：当前组件格式化方法
        testFormatter(prop) {
            return prop
        }
    }
}
</script>
